/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * dlgPatientStatic.java
 *
 * Created on Aug 19, 2012, 2:26:00 PM
 */

package Model.dialog;

import DataBase.DBManagerment;
import DataBase.PikaTableModel;
import Processing.dbclass.Bill;
import Processing.dbclass.Patient;
import Processing.dbclass.Report;
import java.sql.Connection;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;

/**
 *
 * @author Admin
 */
public class dlgPatientStatic extends javax.swing.JDialog {

    /** Creates new form dlgPatientStatic */
    public dlgPatientStatic(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();

        this.setSize(this.getMinimumSize());

        taPatientAdress.setEditable(false);
        taDoctorReport.setEditable(false);
        taPatientReport.setEditable(false);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pnlPatientAdd = new javax.swing.JPanel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jScrollPane10 = new javax.swing.JScrollPane();
        taPatientAdress = new javax.swing.JTextArea();
        jLabel27 = new javax.swing.JLabel();
        lblPatientID = new javax.swing.JLabel();
        lblPatientLastName = new javax.swing.JLabel();
        lblPatientFirstName = new javax.swing.JLabel();
        lblPatientPhoneNo = new javax.swing.JLabel();
        lblPatientGender = new javax.swing.JLabel();
        lblPatientDateOfBirth = new javax.swing.JLabel();
        pnlBill = new javax.swing.JPanel();
        pnlBillInfo = new javax.swing.JPanel();
        jLabel17 = new javax.swing.JLabel();
        cbbBillID = new javax.swing.JComboBox();
        jLabel28 = new javax.swing.JLabel();
        lblBillPaid = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        lblColectorName = new javax.swing.JLabel();
        lblColectorID = new javax.swing.JLabel();
        jLabel39 = new javax.swing.JLabel();
        jLabel40 = new javax.swing.JLabel();
        lblBillAmount = new javax.swing.JLabel();
        lblBillDatePaid = new javax.swing.JLabel();
        jLabel38 = new javax.swing.JLabel();
        lblBillDateMade = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        pnlPurchase = new javax.swing.JPanel();
        pnlTestPurchase = new javax.swing.JPanel();
        jScrollPane7 = new javax.swing.JScrollPane();
        tbTestPurchase = new javax.swing.JTable();
        pnlTestPurchaseTotal = new javax.swing.JPanel();
        lblTestPurchaseTotal = new javax.swing.JLabel();
        pnlStockPurcahse = new javax.swing.JPanel();
        jst2 = new javax.swing.JScrollPane();
        tbStockPurchase = new javax.swing.JTable();
        pnlStockPurchaseTotal = new javax.swing.JPanel();
        lblStockPurchaseTotal = new javax.swing.JLabel();
        pnlReport = new javax.swing.JPanel();
        jLabel29 = new javax.swing.JLabel();
        cbbReportID = new javax.swing.JComboBox();
        jLabel30 = new javax.swing.JLabel();
        lblReportTestPurchase = new javax.swing.JLabel();
        jLabel36 = new javax.swing.JLabel();
        lblReportDoctorID = new javax.swing.JLabel();
        jLabel37 = new javax.swing.JLabel();
        lblReportDoctorName = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        lblReportDateMade = new javax.swing.JLabel();
        jLabel32 = new javax.swing.JLabel();
        jScrollPane14 = new javax.swing.JScrollPane();
        taPatientReport = new javax.swing.JTextArea();
        jLabel33 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        jScrollPane15 = new javax.swing.JScrollPane();
        taDoctorReport = new javax.swing.JTextArea();
        lblReportTest = new javax.swing.JLabel();
        jLabel31 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Patient Statics");
        setMinimumSize(new java.awt.Dimension(925, 675));
        setResizable(false);

        pnlPatientAdd.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        pnlPatientAdd.setMaximumSize(new java.awt.Dimension(925, 115));
        pnlPatientAdd.setPreferredSize(new java.awt.Dimension(925, 115));

        jLabel14.setText("Patient's ID:");

        jLabel15.setText("First Name:");

        jLabel16.setText("Last Name:");

        jLabel21.setText("Address:");

        jLabel22.setText("Phone No:");

        jLabel23.setText("Gender:");

        taPatientAdress.setColumns(20);
        taPatientAdress.setRows(5);
        jScrollPane10.setViewportView(taPatientAdress);

        jLabel27.setText("Date of Birth:");

        lblPatientID.setFont(new java.awt.Font("Tahoma", 0, 14));
        lblPatientID.setForeground(new java.awt.Color(102, 51, 0));
        lblPatientID.setText("N/A");

        lblPatientLastName.setFont(new java.awt.Font("Tahoma", 0, 14));
        lblPatientLastName.setForeground(new java.awt.Color(102, 51, 0));
        lblPatientLastName.setText("N/A");

        lblPatientFirstName.setFont(new java.awt.Font("Tahoma", 0, 14));
        lblPatientFirstName.setForeground(new java.awt.Color(102, 51, 0));
        lblPatientFirstName.setText("N/A");

        lblPatientPhoneNo.setFont(new java.awt.Font("Tahoma", 0, 14));
        lblPatientPhoneNo.setForeground(new java.awt.Color(102, 51, 0));
        lblPatientPhoneNo.setText("N/A");

        lblPatientGender.setFont(new java.awt.Font("Tahoma", 0, 14));
        lblPatientGender.setForeground(new java.awt.Color(102, 51, 0));
        lblPatientGender.setText("N/A");

        lblPatientDateOfBirth.setFont(new java.awt.Font("Tahoma", 0, 14));
        lblPatientDateOfBirth.setForeground(new java.awt.Color(102, 51, 0));
        lblPatientDateOfBirth.setText("N/A");

        javax.swing.GroupLayout pnlPatientAddLayout = new javax.swing.GroupLayout(pnlPatientAdd);
        pnlPatientAdd.setLayout(pnlPatientAddLayout);
        pnlPatientAddLayout.setHorizontalGroup(
            pnlPatientAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlPatientAddLayout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addGroup(pnlPatientAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel14)
                    .addComponent(jLabel16)
                    .addComponent(jLabel15))
                .addGap(18, 18, 18)
                .addGroup(pnlPatientAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblPatientLastName, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(pnlPatientAddLayout.createSequentialGroup()
                        .addGroup(pnlPatientAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblPatientID, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblPatientFirstName, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(82, 82, 82)
                        .addGroup(pnlPatientAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel27)
                            .addComponent(jLabel23)
                            .addComponent(jLabel22))
                        .addGap(18, 18, 18)
                        .addGroup(pnlPatientAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnlPatientAddLayout.createSequentialGroup()
                                .addComponent(lblPatientPhoneNo, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(58, 58, 58)
                                .addComponent(jLabel21))
                            .addComponent(lblPatientGender, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblPatientDateOfBirth, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane10, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(47, Short.MAX_VALUE))
        );
        pnlPatientAddLayout.setVerticalGroup(
            pnlPatientAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlPatientAddLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlPatientAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jScrollPane10, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, pnlPatientAddLayout.createSequentialGroup()
                        .addGroup(pnlPatientAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel14)
                            .addComponent(lblPatientID)
                            .addComponent(jLabel22)
                            .addComponent(lblPatientPhoneNo)
                            .addComponent(jLabel21))
                        .addGap(18, 18, 18)
                        .addGroup(pnlPatientAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel16)
                            .addComponent(lblPatientLastName)
                            .addComponent(jLabel23)
                            .addComponent(lblPatientGender))
                        .addGap(18, 18, 18)
                        .addGroup(pnlPatientAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel15)
                            .addComponent(lblPatientFirstName)
                            .addComponent(jLabel27)
                            .addComponent(lblPatientDateOfBirth))))
                .addContainerGap())
        );

        getContentPane().add(pnlPatientAdd, java.awt.BorderLayout.NORTH);

        pnlBill.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        pnlBill.setMaximumSize(new java.awt.Dimension(925, 2147483647));
        pnlBill.setPreferredSize(new java.awt.Dimension(901, 180));
        pnlBill.setLayout(new java.awt.BorderLayout());

        pnlBillInfo.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        pnlBillInfo.setMaximumSize(new java.awt.Dimension(925, 100));
        pnlBillInfo.setPreferredSize(new java.awt.Dimension(903, 100));

        jLabel17.setText("Bill's ID:");

        cbbBillID.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbbBillIDItemStateChanged(evt);
            }
        });

        jLabel28.setText("Paid:");

        lblBillPaid.setFont(new java.awt.Font("Tahoma", 0, 14));
        lblBillPaid.setForeground(new java.awt.Color(102, 51, 0));
        lblBillPaid.setText("N/A");

        jLabel19.setText("Collector's ID:");

        jLabel24.setText("Collector's Name:");
        jLabel24.setToolTipText("");

        lblColectorName.setFont(new java.awt.Font("Tahoma", 0, 14));
        lblColectorName.setForeground(new java.awt.Color(102, 51, 0));
        lblColectorName.setText("N/A");

        lblColectorID.setFont(new java.awt.Font("Tahoma", 0, 14));
        lblColectorID.setForeground(new java.awt.Color(102, 51, 0));
        lblColectorID.setText("N/A");

        jLabel39.setText("Date Made:");

        jLabel40.setText("Date Paid:");

        lblBillAmount.setFont(new java.awt.Font("Tahoma", 0, 14));
        lblBillAmount.setForeground(new java.awt.Color(0, 102, 0));
        lblBillAmount.setText("N/A");

        lblBillDatePaid.setFont(new java.awt.Font("Tahoma", 0, 14));
        lblBillDatePaid.setForeground(new java.awt.Color(102, 51, 0));
        lblBillDatePaid.setText("N/A");

        jLabel38.setText("Amount:");

        lblBillDateMade.setFont(new java.awt.Font("Tahoma", 0, 14));
        lblBillDateMade.setForeground(new java.awt.Color(102, 51, 0));
        lblBillDateMade.setText("N/A");

        jButton1.setText("Update");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlBillInfoLayout = new javax.swing.GroupLayout(pnlBillInfo);
        pnlBillInfo.setLayout(pnlBillInfoLayout);
        pnlBillInfoLayout.setHorizontalGroup(
            pnlBillInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlBillInfoLayout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addGroup(pnlBillInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlBillInfoLayout.createSequentialGroup()
                        .addComponent(jLabel17)
                        .addGap(18, 18, 18)
                        .addComponent(cbbBillID, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(pnlBillInfoLayout.createSequentialGroup()
                        .addGap(24, 24, 24)
                        .addComponent(jButton1)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 102, Short.MAX_VALUE)
                .addGroup(pnlBillInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel24)
                    .addComponent(jLabel19))
                .addGap(18, 18, 18)
                .addGroup(pnlBillInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblColectorID, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblColectorName, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(66, 66, 66)
                .addGroup(pnlBillInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel39)
                    .addComponent(jLabel40))
                .addGap(18, 18, 18)
                .addGroup(pnlBillInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblBillDateMade, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblBillDatePaid, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(75, 75, 75)
                .addGroup(pnlBillInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel38)
                    .addComponent(jLabel28))
                .addGap(18, 18, 18)
                .addGroup(pnlBillInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblBillPaid, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblBillAmount, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        pnlBillInfoLayout.setVerticalGroup(
            pnlBillInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlBillInfoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlBillInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(cbbBillID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel38)
                    .addComponent(jLabel19)
                    .addComponent(lblColectorID)
                    .addComponent(jLabel39)
                    .addComponent(lblBillDateMade)
                    .addComponent(lblBillAmount))
                .addGap(18, 18, 18)
                .addGroup(pnlBillInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel24)
                    .addComponent(lblColectorName)
                    .addComponent(jLabel40)
                    .addComponent(lblBillDatePaid)
                    .addComponent(jButton1)
                    .addComponent(jLabel28)
                    .addComponent(lblBillPaid))
                .addContainerGap(24, Short.MAX_VALUE))
        );

        pnlBill.add(pnlBillInfo, java.awt.BorderLayout.PAGE_START);

        pnlPurchase.setLayout(new javax.swing.BoxLayout(pnlPurchase, javax.swing.BoxLayout.LINE_AXIS));

        pnlTestPurchase.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        pnlTestPurchase.setPreferredSize(new java.awt.Dimension(250, 250));
        pnlTestPurchase.setLayout(new java.awt.BorderLayout());

        tbTestPurchase.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        tbTestPurchase.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        tbTestPurchase.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                tbTestPurchasePropertyChange(evt);
            }
        });
        jScrollPane7.setViewportView(tbTestPurchase);

        pnlTestPurchase.add(jScrollPane7, java.awt.BorderLayout.CENTER);

        pnlTestPurchaseTotal.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        pnlTestPurchaseTotal.setPreferredSize(new java.awt.Dimension(740, 25));
        pnlTestPurchaseTotal.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));

        lblTestPurchaseTotal.setFont(new java.awt.Font("Tahoma", 1, 11));
        lblTestPurchaseTotal.setText("Total Test Purchase: 0");
        pnlTestPurchaseTotal.add(lblTestPurchaseTotal);

        pnlTestPurchase.add(pnlTestPurchaseTotal, java.awt.BorderLayout.PAGE_START);

        pnlPurchase.add(pnlTestPurchase);

        pnlStockPurcahse.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        pnlStockPurcahse.setPreferredSize(new java.awt.Dimension(250, 250));
        pnlStockPurcahse.setLayout(new java.awt.BorderLayout());

        tbStockPurchase.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        tbStockPurchase.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        tbStockPurchase.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                tbStockPurchasePropertyChange(evt);
            }
        });
        jst2.setViewportView(tbStockPurchase);

        pnlStockPurcahse.add(jst2, java.awt.BorderLayout.CENTER);

        pnlStockPurchaseTotal.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        pnlStockPurchaseTotal.setPreferredSize(new java.awt.Dimension(740, 25));
        pnlStockPurchaseTotal.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));

        lblStockPurchaseTotal.setFont(new java.awt.Font("Tahoma", 1, 11));
        lblStockPurchaseTotal.setText("Total Stock Purchase: 0");
        pnlStockPurchaseTotal.add(lblStockPurchaseTotal);

        pnlStockPurcahse.add(pnlStockPurchaseTotal, java.awt.BorderLayout.PAGE_START);

        pnlPurchase.add(pnlStockPurcahse);

        pnlBill.add(pnlPurchase, java.awt.BorderLayout.CENTER);

        getContentPane().add(pnlBill, java.awt.BorderLayout.CENTER);

        pnlReport.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        pnlReport.setPreferredSize(new java.awt.Dimension(903, 250));

        jLabel29.setText("Report's ID:");

        cbbReportID.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbbReportIDItemStateChanged(evt);
            }
        });

        jLabel30.setText("Test Purchase's ID:");

        lblReportTestPurchase.setFont(new java.awt.Font("Tahoma", 0, 14));
        lblReportTestPurchase.setForeground(new java.awt.Color(102, 51, 0));
        lblReportTestPurchase.setText("N/A");

        jLabel36.setText("Doctor's ID:");

        lblReportDoctorID.setFont(new java.awt.Font("Tahoma", 0, 14));
        lblReportDoctorID.setForeground(new java.awt.Color(102, 51, 0));
        lblReportDoctorID.setText("N/A");

        jLabel37.setText("Doctor's Name:");

        lblReportDoctorName.setFont(new java.awt.Font("Tahoma", 0, 14));
        lblReportDoctorName.setForeground(new java.awt.Color(102, 51, 0));
        lblReportDoctorName.setText("N/A");

        jLabel26.setText("Date Made:");

        lblReportDateMade.setFont(new java.awt.Font("Tahoma", 0, 14));
        lblReportDateMade.setForeground(new java.awt.Color(102, 51, 0));
        lblReportDateMade.setText("N/A");

        jLabel32.setText("Patient's Report:");

        taPatientReport.setColumns(20);
        taPatientReport.setRows(5);
        jScrollPane14.setViewportView(taPatientReport);

        jLabel33.setText("Doctor's Report:");

        jButton2.setText("Update");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        taDoctorReport.setColumns(20);
        taDoctorReport.setRows(5);
        jScrollPane15.setViewportView(taDoctorReport);

        lblReportTest.setFont(new java.awt.Font("Tahoma", 0, 14));
        lblReportTest.setForeground(new java.awt.Color(102, 51, 0));
        lblReportTest.setText("N/A");

        jLabel31.setText("Test :");

        javax.swing.GroupLayout pnlReportLayout = new javax.swing.GroupLayout(pnlReport);
        pnlReport.setLayout(pnlReportLayout);
        pnlReportLayout.setHorizontalGroup(
            pnlReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlReportLayout.createSequentialGroup()
                .addGroup(pnlReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlReportLayout.createSequentialGroup()
                        .addGap(32, 32, 32)
                        .addGroup(pnlReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel30)
                            .addComponent(jLabel29)
                            .addComponent(jLabel31)
                            .addComponent(jLabel36)
                            .addComponent(jLabel37)
                            .addComponent(jLabel26))
                        .addGap(18, 18, 18)
                        .addGroup(pnlReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblReportDateMade, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblReportDoctorID, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(pnlReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(lblReportTestPurchase, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(cbbReportID, 0, 74, Short.MAX_VALUE))
                            .addGroup(pnlReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(lblReportDoctorName, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(lblReportTest, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE))))
                    .addGroup(pnlReportLayout.createSequentialGroup()
                        .addGap(95, 95, 95)
                        .addComponent(jButton2)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 44, Short.MAX_VALUE)
                .addComponent(jLabel32)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane14, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(58, 58, 58)
                .addComponent(jLabel33)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane15, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(34, 34, 34))
        );
        pnlReportLayout.setVerticalGroup(
            pnlReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlReportLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, pnlReportLayout.createSequentialGroup()
                        .addComponent(jLabel32)
                        .addGap(188, 188, 188))
                    .addComponent(jScrollPane15, javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, pnlReportLayout.createSequentialGroup()
                        .addComponent(jLabel33)
                        .addGap(97, 97, 97))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, pnlReportLayout.createSequentialGroup()
                        .addGroup(pnlReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel29)
                            .addComponent(cbbReportID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(pnlReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel30)
                            .addComponent(lblReportTestPurchase))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(pnlReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblReportTest)
                            .addComponent(jLabel31))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(pnlReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel36)
                            .addComponent(lblReportDoctorID))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(pnlReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblReportDoctorName)
                            .addComponent(jLabel37))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(pnlReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblReportDateMade)
                            .addComponent(jLabel26))
                        .addGap(18, 18, 18)
                        .addComponent(jButton2))
                    .addComponent(jScrollPane14, javax.swing.GroupLayout.Alignment.LEADING))
                .addGap(52, 52, 52))
        );

        getContentPane().add(pnlReport, java.awt.BorderLayout.PAGE_END);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void cbbBillIDItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbBillIDItemStateChanged
        // TODO add your handling code here:
        String biID = cbbBillID.getSelectedItem().toString();

        if (biID != null) {
            if (db.searchBilling(con, 1, biID).getValueAt(0, 3) != null) {
                lblColectorID.setText(db.searchBilling(con, 1, biID).getValueAt(0, 3).toString());
                lblColectorName.setText(db.searchBilling(con, 1, biID).getValueAt(0, 4).toString());

                lblBillDatePaid.setText(db.searchBilling(con, 1, biID).getValueAt(0, 7).toString());
            }else{
                lblColectorID.setText("N/A");
                lblColectorName.setText("N/A");

                lblBillDatePaid.setText("N/A");
            }

            lblBillDateMade.setText(db.searchBilling(con, 1, biID).getValueAt(0, 6).toString());
            lblBillAmount.setText(db.searchBilling(con, 1, biID).getValueAt(0, 5).toString());
            lblBillPaid.setText(db.searchBilling(con, 1, biID).getValueAt(0, 8).toString());

            // Lấy purchase theo biID
            tbTestPurchase.setModel(db.searchTestPurchase(con, biID));
            tbStockPurchase.setModel(db.searchStockPurchase(con, biID));
        }
        
    }//GEN-LAST:event_cbbBillIDItemStateChanged

    private void cbbReportIDItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbReportIDItemStateChanged
        // TODO add your handling code here:
        String reID = cbbReportID.getSelectedItem().toString();

        if (reID != null) {
            lblReportTestPurchase.setText(db.searchReport(con, 1, reID).getValueAt(0, 1).toString());
            lblReportTest.setText(db.searchReport(con, 1, reID).getValueAt(0, 3).toString());
            
            if (db.searchReport(con, 1, reID).getValueAt(0, 6) != null) {
                lblReportDoctorID.setText(db.searchReport(con, 1, reID).getValueAt(0, 6).toString());
                lblReportDoctorName.setText(db.searchReport(con, 1, reID).getValueAt(0, 7).toString());
            }else{
                lblReportDoctorID.setText("N/A");
                lblReportDoctorID.setText("N/A");
            }          

            lblReportDateMade.setText(db.searchReport(con, 1, reID).getValueAt(0, 8).toString());
            taPatientReport.setText(db.searchReport(con, 1, reID).getValueAt(0, 9).toString());
            taDoctorReport.setText(db.searchReport(con, 1, reID).getValueAt(0, 10).toString());
        }
        
    }//GEN-LAST:event_cbbReportIDItemStateChanged

    private void tbTestPurchasePropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_tbTestPurchasePropertyChange
        // TODO add your handling code here:
        lblTestPurchaseTotal.setText("Total Test Purchase: " + tbTestPurchase.getRowCount());

        if (tbTestPurchase.getModel().getColumnCount() > 0) {
            tbTestPurchase.getColumnModel().getColumn(0).setPreferredWidth(125);
            tbTestPurchase.getColumnModel().getColumn(1).setPreferredWidth(65);
            tbTestPurchase.getColumnModel().getColumn(2).setPreferredWidth(65);
            tbTestPurchase.getColumnModel().getColumn(3).setPreferredWidth(125);
            tbTestPurchase.getColumnModel().getColumn(4).setPreferredWidth(60);
            tbTestPurchase.getColumnModel().getColumn(5).setPreferredWidth(90);
        }
}//GEN-LAST:event_tbTestPurchasePropertyChange

    private void tbStockPurchasePropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_tbStockPurchasePropertyChange
        // TODO add your handling code here:
        lblStockPurchaseTotal.setText("Total Stock Purchase:  " + tbStockPurchase.getRowCount());

        if (tbStockPurchase.getModel().getColumnCount() > 0) {
            tbStockPurchase.getColumnModel().getColumn(0).setPreferredWidth(125);
            tbStockPurchase.getColumnModel().getColumn(1).setPreferredWidth(65);
            tbStockPurchase.getColumnModel().getColumn(2).setPreferredWidth(65);
            tbStockPurchase.getColumnModel().getColumn(3).setPreferredWidth(125);
            tbStockPurchase.getColumnModel().getColumn(4).setPreferredWidth(60);
            tbStockPurchase.getColumnModel().getColumn(5).setPreferredWidth(60);
            tbStockPurchase.getColumnModel().getColumn(6).setPreferredWidth(90);
        }
}//GEN-LAST:event_tbStockPurchasePropertyChange

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        if (db.searchStaff(con, 1, staffID).getValueAt(0, 3).toString().equalsIgnoreCase("Server Admin") || db.searchStaff(con, 1, staffID).getValueAt(0, 3).toString().equalsIgnoreCase("Doctor")) {
            // Lấy StaffId từ select ở bảng bên dưới
            // Các thứ cần sửa lại:
            // staffId: Sửa thành Id phù hợp
            // tbStaffList: sửa thành bảng tương ứng(bảng liệt kể list vd: Staff ngay bên dưới nút delete)
            if (cbbReportID.getSelectedItem() != null) {
                int reportID = Integer.parseInt(cbbReportID.getSelectedItem().toString());

                dlgEditReport dlgEidreport = new dlgEditReport(null, true);

                Report re = new Report();

                re.setReportID(reportID);

                dlgEidreport.setReport(re);

                // Lệnh này hiển thị dialog ở chính giữa chương trình
                dlgEidreport.setLocationRelativeTo(this);

                // hiển thị dialog
                dlgEidreport.setVisible(true);

                if (dlgEidreport.getReport().getPatientID() != null) {
                    // Thông báo: Hỏi xem người dùng có muốn xóa ko, biến choice lưu lại lựa chọn của người
                    // dùng ở dialog bật lên
                    // Khi copy nhớ sửa lại thông báo cho phù hợp
                    int choice = JOptionPane.showConfirmDialog(this, "Are you sure to edit Report: " + reportID + "?");

                    // Nếu người dùng chọn yes ở bảng dialog bật lên
                    if (choice == JOptionPane.YES_OPTION) {
                        // Gọi method xóa Staff
                        // Copy nhớ chỉnh lại thành method tương ứng
                        db.editReport(con, reportID, dlgEidreport.getReport());
                    }

                }

                loadDB();
            }
        }else {
            JOptionPane.showMessageDialog(this, "You do not have permission to do this!");
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        int billID = Integer.parseInt(cbbBillID.getSelectedItem().toString());

        dlgEditBill dlgEidBill = new dlgEditBill(null, true);

        Bill bil = new Bill();

        bil.setBillID(billID);

        dlgEidBill.setStaffID(staffID);

        dlgEidBill.setBill(bil);

        // Lệnh này hiển thị dialog ở chính giữa chương trình
        dlgEidBill.setLocationRelativeTo(this);

        // hiển thị dialog
        dlgEidBill.setVisible(true);

        // Hiển thị lại bảng Staff sau khi đã xóa
        // Chỉnh lại bảng và method hiển thị tương ứng
        loadDB();

        if (dlgEidBill.getReportTestP() != null) {
            dlgAddReport dlgReport = new dlgAddReport(null, true);

            dlgReport.getTxtReportTestPurchase().setText(dlgEidBill.getReportTestP());

            // Lệnh này hiển thị dialog ở chính giữa chương trình
            dlgReport.setLocationRelativeTo(this);

            dlgReport.setStaffID(staffID);

            // hiển thị dialog
            dlgReport.setVisible(true);

            // Kiểm tra xem bill của dialog có trống ko(nếu người dùng nhấn
            // cancel thì bill sẽ bị trống)
            if (dlgReport.getReport() != null) {
                // Gọi method add thôi
                if (db.addReport(con, dlgReport.getReport())) {
                    JOptionPane.showMessageDialog(this, "Add successful!");
                } else {
                    JOptionPane.showMessageDialog(this, "Add failures!");
                }
            }
        }
    }//GEN-LAST:event_jButton1ActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                dlgPatientStatic dialog = new dlgPatientStatic(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    /**
     * Method gán giấ trị cho PatientID
     * @param PatientID
     */
    public void setPatientID(int PatientID) {
        this.PatientID = PatientID;
    }

    /**
     * Method gán giá trị cho BillID
     * @param BillID
     */
    public void setBillID(String BillID) {
        this.BillID = BillID;
    }

    /**
     * Method gán giá trị cho ReportID
     * @param ReportID
     */
    public void setReportID(String ReportID) {
        this.ReportID = ReportID;
    }

    /**
     * MEthod này có nhiệm vụ load hết thông tin vào form
     */
    public void loadDB(){
        Patient pati = db.generatePatient(con, PatientID);

        // Load form patient
        lblPatientID.setText(""+PatientID);
        lblPatientFirstName.setText(pati.getFirstName());
        lblPatientLastName.setText(pati.getLastName());
        lblPatientPhoneNo.setText(pati.getPhoneNo());
        lblPatientGender.setText(db.searchPatient(con, 1, ""+PatientID).getValueAt(0, 5).toString());
        lblPatientDateOfBirth.setText(db.searchPatient(con, 1, ""+PatientID).getValueAt(0, 2).toString());
        taPatientAdress.setText(db.searchPatient(con, 1, ""+PatientID).getValueAt(0, 3).toString());
        
        // Load form Bill
        DefaultComboBoxModel combo = new DefaultComboBoxModel();

        PikaTableModel billPika = db.searchBilling(con, 2, ""+PatientID);

        for (int i = 0; i < billPika.getRowCount(); i++) {
            combo.addElement(billPika.getValueAt(i, 0));
        }

        cbbBillID.setModel(combo);

        String biID = null;

        if (BillID != null) {
            cbbBillID.setSelectedItem(BillID);

        }

        if (cbbBillID.getSelectedItem() != null) {
            biID = cbbBillID.getSelectedItem().toString();

        }


        if (biID != null) {
            if (db.searchBilling(con, 1, biID).getValueAt(0, 3) != null) {
                lblColectorID.setText(db.searchBilling(con, 1, biID).getValueAt(0, 3).toString());
                lblColectorName.setText(db.searchBilling(con, 1, biID).getValueAt(0, 4).toString());

                lblBillDatePaid.setText(db.searchBilling(con, 1, biID).getValueAt(0, 7).toString());
            }

            lblBillDateMade.setText(db.searchBilling(con, 1, biID).getValueAt(0, 6).toString());
            lblBillAmount.setText(db.searchBilling(con, 1, biID).getValueAt(0, 5).toString());
            lblBillPaid.setText(db.searchBilling(con, 1, biID).getValueAt(0, 8).toString());

            // Lấy purchase theo biID
            tbTestPurchase.setModel(db.searchTestPurchase(con, biID));
            tbStockPurchase.setModel(db.searchStockPurchase(con, biID));
        }

        // Lấy dữ liệu đổ vào form report
        combo = new DefaultComboBoxModel();

        PikaTableModel reportPika = db.searchReport(con, 3, ""+PatientID);

        for (int i = 0; i < reportPika.getRowCount(); i++) {
            combo.addElement(reportPika.getValueAt(i, 0));
        }

        cbbReportID.setModel(combo);

        String reID = null;

        if (ReportID != null) {
            cbbReportID.setSelectedItem(ReportID);

        }

        if (cbbReportID.getSelectedItem() != null) {
            reID = cbbReportID.getSelectedItem().toString();

        }

        if (reID != null) {
            lblReportTestPurchase.setText(db.searchReport(con, 1, reID).getValueAt(0, 1).toString());
            lblReportTest.setText(db.searchReport(con, 1, reID).getValueAt(0, 3).toString());
            lblReportDoctorID.setText(db.searchReport(con, 1, reID).getValueAt(0, 6).toString());
            lblReportDoctorName.setText(db.searchReport(con, 1, reID).getValueAt(0, 7).toString());
            lblReportDateMade.setText(db.searchReport(con, 1, reID).getValueAt(0, 8).toString());
            taPatientReport.setText(db.searchReport(con, 1, reID).getValueAt(0, 9).toString());
            taDoctorReport.setText(db.searchReport(con, 1, reID).getValueAt(0, 10).toString());
        }

        this.setTitle("Patient Statics - " + lblPatientID.getText() + " - " + lblPatientFirstName.getText() + " " + lblPatientLastName.getText() );
    }

    /**
     * Đối tượng của class DBManagerment
     */
    private DBManagerment db = new DBManagerment();

    /**
     * Một Connection
     */
    private Connection con = db.ConnectServer();

    /**
     * Biến chứa PatientID người dùng cần xem static
     */
    private int PatientID = 0;

    /**
     * Biến chứa BillID người dùng cần xem static
     */
    private String BillID = null;

    /**
     * Biến chứa ReportID người dùng cần xem Static
     */
    private String ReportID = null;

    /**
     * Bien chua staffID dang nhap
     */
    private String staffID = null;

    public void setStaffID(String staffID) {
        this.staffID = staffID;

         if (db.searchStaff(con, 1, staffID).getValueAt(0, 3).toString().equalsIgnoreCase("Server Admin")) {

            jButton1.setEnabled(false);
            jButton2.setEnabled(false);
        }else{
            jButton1.setEnabled(true);
            jButton2.setEnabled(true);
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox cbbBillID;
    private javax.swing.JComboBox cbbReportID;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel36;
    private javax.swing.JLabel jLabel37;
    private javax.swing.JLabel jLabel38;
    private javax.swing.JLabel jLabel39;
    private javax.swing.JLabel jLabel40;
    private javax.swing.JScrollPane jScrollPane10;
    private javax.swing.JScrollPane jScrollPane14;
    private javax.swing.JScrollPane jScrollPane15;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jst2;
    private javax.swing.JLabel lblBillAmount;
    private javax.swing.JLabel lblBillDateMade;
    private javax.swing.JLabel lblBillDatePaid;
    private javax.swing.JLabel lblBillPaid;
    private javax.swing.JLabel lblColectorID;
    private javax.swing.JLabel lblColectorName;
    private javax.swing.JLabel lblPatientDateOfBirth;
    private javax.swing.JLabel lblPatientFirstName;
    private javax.swing.JLabel lblPatientGender;
    private javax.swing.JLabel lblPatientID;
    private javax.swing.JLabel lblPatientLastName;
    private javax.swing.JLabel lblPatientPhoneNo;
    private javax.swing.JLabel lblReportDateMade;
    private javax.swing.JLabel lblReportDoctorID;
    private javax.swing.JLabel lblReportDoctorName;
    private javax.swing.JLabel lblReportTest;
    private javax.swing.JLabel lblReportTestPurchase;
    private javax.swing.JLabel lblStockPurchaseTotal;
    private javax.swing.JLabel lblTestPurchaseTotal;
    private javax.swing.JPanel pnlBill;
    private javax.swing.JPanel pnlBillInfo;
    private javax.swing.JPanel pnlPatientAdd;
    private javax.swing.JPanel pnlPurchase;
    private javax.swing.JPanel pnlReport;
    private javax.swing.JPanel pnlStockPurcahse;
    private javax.swing.JPanel pnlStockPurchaseTotal;
    private javax.swing.JPanel pnlTestPurchase;
    private javax.swing.JPanel pnlTestPurchaseTotal;
    private javax.swing.JTextArea taDoctorReport;
    private javax.swing.JTextArea taPatientAdress;
    private javax.swing.JTextArea taPatientReport;
    private javax.swing.JTable tbStockPurchase;
    private javax.swing.JTable tbTestPurchase;
    // End of variables declaration//GEN-END:variables

}
